package com.example.demo.controller;

import com.example.demo.model.AccountWallet;
import com.example.demo.model.User;
import com.example.demo.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;

@RestController
@Slf4j
public class TestController {
    @Autowired
    TestService accountWalletService;

    @PostMapping(value="/test")
    @ResponseBody
    public void test() {
        List<User> users = accountWalletService.initUsers();
        //模拟并发
        users.parallelStream().forEach(b -> {
            try {
                accountWalletService.process(b);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

    }
}
